package com.alibaba.serverless.service.handle.v20201108.config;

import com.alibaba.serverless.service.handle.BaseSmtpStrategy;
import com.alibaba.serverless.service.handle.v20201108.impl.IBaseSmtpCheckStrategyImpl;
import com.alibaba.serverless.service.handle.v20201108.impl.IBaseSmtpResultStrategyImpl;
/**
 * 邮件发送类型
 * @author mac_zyj
 */

public enum  SmtpSendType {
    /**校验策略*/
    CHECK_TYPE("校验",1,new IBaseSmtpCheckStrategyImpl()),
    /**结果策略*/
    RESULT_TYPE("结果",2,new IBaseSmtpResultStrategyImpl()),
    /**推送策略*/
    PUSH_TYPE("推送",3,null),
    /**默认策略*/
    OTHER("其他",4,null);
    /**类型名称*/
    private final String typeName;
    /**类型*/
    private final int type;
    /**策略*/
    private final BaseSmtpStrategy baseSmtpStrategy;

    SmtpSendType(String typeName, int type, BaseSmtpStrategy baseSmtpStrategy) {
        this.typeName = typeName;
        this.type = type;
        this.baseSmtpStrategy = baseSmtpStrategy;
    }

    public String getTypeName() {
        return typeName;
    }

    public int getType() {
        return type;
    }

    public BaseSmtpStrategy getSmtpStrategy() {
        return baseSmtpStrategy;
    }

    public static BaseSmtpStrategy getSmtpStrategyByType(int type){
        for (SmtpSendType sendType:values()){
            if (sendType.getType()==type){
                return sendType.getSmtpStrategy();
            }
        }
        return null;
    }
    public static String getTypeNameByType(int type){
        for (SmtpSendType sendType:values()){
            if (sendType.getType()==type){
                return sendType.getTypeName();
            }
        }
        return null;
    }
}
